WPF and Silverlight Edition Basic Library > Combo Box > ComboBox Features > ComboBox Items > Selecting Items |
The SelectedIndex property determines which item is selected in a drop-down list. The SelectedIndex is based on a zero-based index, meaning that 0 represents the first C1ComboBoxItem, 1 represents the second C1ComboBoxItem, and so on. In the image below, the SelectedIndex is set to 2, which selects the third C1ComboBoxItem.
To set a selected item, add SelectedIndex="0" to the <c1:C1ComboBoxItem> tag so that the markup resembles the following:
XAML |
Copy Code
|
---|---|
<c1:C1ComboBoxItem Content="C1ComboBoxItem1" SelectedIndex="1"> |
Complete the following steps:
Visual Basic Copy Code C1ComboBoxItem1.SelectedIndex = 1
C# Copy Code c1ComboBoxItem1.SelectedIndex = 1;
Complete the following steps: